//
//  ViewController.m
//  06_Work
//
//  Created by dllo on 16/7/21.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "RegViewController.h"
#import "ForgetViewController.h"
#import "ImageTextView.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    // 1.更换拉钩登陆、注册、忘记密码等页面的切换方式, 使用NavgationController管理
#if 0
    self.view.backgroundColor = [UIColor redColor];
    self.navigationController.navigationBarHidden = YES;
    
    UIView *backView = [ImageTextView createBackViewFrame:self.view.frame];
    [self.view addSubview:backView];
    
    UIView *textFieldView = [ImageTextView createViewFrame:CGRectMake(10, 350, WIDTH - 20, 82) backGroundColor:[UIColor clearColor]];
    [backView addSubview:textFieldView];
    
    UIImageView *logoImageView = [ImageTextView createLogeViewFrame:CGRectMake(WIDTH / 2 - 60, 100, 120, 200)];
    [self.view addSubview:logoImageView];
    
    UIButton *logButton = [ImageTextView createLoginButtonFrame:CGRectMake(10, 455, WIDTH - 20 , 40)];
    [self.view addSubview:logButton];
    
    UIButton *forgetButton = [ImageTextView createForgetKeyButtonFrame:CGRectMake(7, 510, 80, 40)];
    [self.view addSubview:forgetButton];
    [forgetButton addTarget:self action:@selector(forgetClick:) forControlEvents:UIControlEventTouchUpInside];
    
    
    UIButton *regButton = [ImageTextView createRegButtonFrame:CGRectMake(120, 540, WIDTH - 240, 40)];
    [self.view addSubview:regButton];
    [regButton addTarget:self action:@selector(logClick:) forControlEvents:UIControlEventTouchUpInside];
    
    UIView *lineView = [ImageTextView createLineFrame:CGRectMake(0, 610, WIDTH, 30)];
    [self.view addSubview:lineView];
    
    UIButton *strollButton = [ImageTextView createStrollButtonFrame:CGRectMake(WIDTH / 2 - 75, 640, 160, 40)];
    [self.view addSubview:strollButton];
#endif
#if 1
    // 2.模仿QQ聊天页面的NavgationBar
    // QQ navgation
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.267 green:0.655 blue:0.945 alpha:1.000];
    UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"消息", @"电话"]];
    segment.frame = CGRectMake(0, 0, 130, 30);
    segment.tintColor = [UIColor whiteColor];
    segment.layer.borderWidth = 1;
    segment.layer.borderColor = [UIColor whiteColor].CGColor;
    segment.layer.masksToBounds = YES;
    segment.layer.cornerRadius = 5;
    segment.selectedSegmentIndex = 0;
    self.navigationItem.titleView = segment;
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    imageView.layer.cornerRadius = 20;
    UIImage *image = [UIImage imageNamed:@"u=2301975825,1085041863&fm=23&gp=0"];
    [imageView setImage:image];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:imageView];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(click:)];
//    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    
#endif
    // 3.思考: 轮播图pageControl实现轮播效果
}

- (void)logClick:(UIButton *)button {
    RegViewController *vc = [[RegViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)forgetClick:(UIButton *)button {
    ForgetViewController *forget = [[ForgetViewController alloc] init];
    [self.navigationController pushViewController:forget animated:YES];
}

- (void)click:(UIBarButtonItem *)button {
    NSLog(@"cao  nan shou ");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
